{include file="public/layout"/}
<body data-type="generalComponents">
<div class="tpl-content-wrapper">
    <ol class="am-breadcrumb">
        <li><a href="javascript:void(0)" class="am-icon-home" onclick="javascript:parent.openItem('welcome|Index');">首页</a></li>
        <li class="am-active">权限</li>
        <li><a href="{:url('admin/role')}">角色管理</a></li>
        <li class="am-active">管理员 - 编辑角色</li>
    </ol>
    <div class="tpl-portlet-components">
        <div class="tpl-block ">
            <div class="am-g tpl-amazeui-form">
                <div class="am-u-sm-12 am-u-md-9">
                    <form class="am-form am-form-horizontal js-ajax-form" action="{:url('admin/roleSave')}" method="post">
                        <div class="am-form-group">
                            <label for="role_name" class="am-u-sm-3 am-form-label">角色名称</label>
                            <div class="am-u-sm-9">
                                <input type="text" name="data[role_name]" id="role_name" value="{$detail.role_name ?? ''}" placeholder="角色名称" class="required">
                            </div>
                        </div>

                        <div class="am-form-group">
                            <label for=role_desc" class="am-u-sm-3 am-form-label">角色描述</label>
                            <div class="am-u-sm-9">
                                <textarea id="role_desc" name="data[role_desc]" class="tarea" rows="6">{$detail.role_desc ?? ''}</textarea>
                            </div>
                        </div>
                        <div class="am-form-group">
                            <label for="group" class="am-u-sm-3 am-form-label">权限分配</label>
                            <div class="am-u-sm-9">
                            <dl class="row">
                                <dd>
                                    <div class="ncap-account-container" style="border-top:none;">
                                        <h4>
                                            <input id="cls_full" onclick="choosebox(this)" type="checkbox">
                                            <label>全选</label>
                                        </h4>
                                    </div>
                                    {foreach name="modules" item="menu" key="kk"}
                                    <div class="ncap-account-container" style="border-top:none;">
                                        <h4>
                                            <label>{$group[$kk]}</label>
                                            <input value="1" cka="mod-{$kk}" type="checkbox">
                                            <label>全部</label>
                                        </h4>
                                        <ul class="ncap-account-container-list">
                                            {foreach name="menu" item="vv"}
                                            <li>
                                                <label><input class="checkbox" name="right[]" value="{$vv.id}" {if condition="$vv.enable eq 1"}checked{/if} ck="mod-{$kk}" type="checkbox">{$vv.name}</label>
                                            </li>
                                            {/foreach}
                                        </ul>
                                    </div>
                                    {/foreach}
                                </dd>
                            </dl>
                            </div>
                        </div>
                        <input type="hidden" name="role_id" value="{$detail.role_id ?? ''}">
                        <div class="am-form-group">
                            <div class="am-u-sm-9 am-u-sm-push-3">
                                <button type="submit" class="am-btn am-btn-primary js-ajax-submit">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="__ADMIN__/js/admin.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        $(":checkbox[cka]").click(function(){
            var $cks = $(":checkbox[ck='"+$(this).attr("cka")+"']");
            if($(this).is(':checked')){
                $cks.each(function(){$(this).prop("checked",true);});
            }else{
                $cks.each(function(){$(this).removeAttr('checked');});
            }
        });
    });

    function choosebox(o){
        var vt = $(o).is(':checked');
        if(vt){
            $('input[type=checkbox]').prop('checked',vt);
        }else{
            $('input[type=checkbox]').removeAttr('checked');
        }
    }
</script>
</body>
</html>